package com.hxkj.service.impl;

import com.hxkj.client.service.UserServiceClient;
import com.hxkj.domain.enums.UserExceptionEnum;
import com.hxkj.entity.po.Role;
import com.hxkj.service.RoleService;
import com.platform.common.domain.exception.CustomException;
import com.platform.common.domain.result.ResultDataStruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * Create by chenwei on 2018/5/23 15:18
 */
@Service
@Slf4j
public class RoleServiceImpl implements RoleService {

    @Autowired
    private UserServiceClient userServiceClient;

    public Role get(Long roleId) {
        return null;
    }

    public List<Role> get(Role role) {
        return null;
    }

    public int delete(Long roleId) {
        return 0;
    }

    public int delete(String roleIds) throws Exception {
        return 0;
    }

    public int delete(Role role) {
        return 0;
    }

    public int save(Role role) {
        return 0;
    }

    public int update(Role role) {
        return 0;
    }

    public Set<String> findRolesByAccount(String account) throws Exception {
        ResultDataStruct<Set<String>> setResultDataStruct;
        try {
            setResultDataStruct = userServiceClient.findRolesByAccount(account);
            if(setResultDataStruct.getCode() == 200){
                Set<String> strings = setResultDataStruct.getData();
                return strings;
            }else{
                log.error("根据账户查询角色失败:{}","RoleServiceImpl.findRolesByAccount");
                throw new CustomException(UserExceptionEnum.getEnumByCode(setResultDataStruct.getCode()));
            }
        }catch (Exception e){
         log.error("根据账户查询角色失败:{}","RoleServiceImpl.findRolesByAccount");
         throw new CustomException(UserExceptionEnum.GET_ROLE_BY_ACCOUNT_FAIL);

        }
    }

    public List<Role> getRolesByAppKey(String appKey) {
        return null;
    }

    public List<Role> getRolesByAccount(String appKey, String account) {
        return null;
    }

    public Role getOneRole(String appKey, Long roleId) {
        return null;
    }

    public Map<String, Object> getUserAppRole(Long userId, Long appId) {
        return null;
    }
}
